# -*- coding: utf-8 -*-
# @Time    : 2021/1/5 下午1:32
# @Author  : tgy
# https://leetcode-cn.com/problems/best-time-to-buy-and-sell-stock-ii/


class Solution:
    def maxProfit(self, prices):
        ...
        # 买了
        buy = -prices[0]
        # 卖了
        sell = 0

        for i in range(1, len(prices)):
            ...
            tmp_buy = max(sell - prices[i], buy)
            tmp_sell = max(buy + prices[i], sell)
            buy = tmp_buy
            sell = tmp_sell
            print(f'buy:{buy},sell:{sell}')

        return sell


if __name__ == '__main__':
    ...
    solution = Solution()
    max_profit = solution.maxProfit([7, 1, 5, 3, 6, 4])
    print(max_profit)
